using UnityEngine;
using System.Collections;

public class AnimatedUVs : MonoBehaviour 
{
    public int m_MaterialIdx = 0;
    public Vector2 m_UV_Speed = new Vector2( 1.0f, 0.0f );
    public string m_TextureName1 = "_MainTex";
    public string m_TextureName2 = "";
    public string m_TextureName3 = "";

    Vector2 uvOffset = Vector2.zero;

    void Update() 
    {
        uvOffset += ( m_UV_Speed * Time.deltaTime );
        if( renderer.enabled )
        {
			if (m_TextureName1 != "") 
            	renderer.materials[ m_MaterialIdx ].SetTextureOffset( m_TextureName1, uvOffset );
			
			if (m_TextureName2 != "") 
            	renderer.materials[ m_MaterialIdx ].SetTextureOffset( m_TextureName2, uvOffset );
			
			if (m_TextureName3 != "") 
            	renderer.materials[ m_MaterialIdx ].SetTextureOffset( m_TextureName3, uvOffset );
			
        }
    }
}